Skip to content

Merge tree-sitter-fortran #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Jun 25, 2025

Conversation

inaki-amatria
Copy link
Member

This PR updates our fork of tree-sitter-fortran to incorporate the latest changes from upstream.

The update was reviewed in: #11.

ZedThree and others added 30 commits April 3, 2025 17:13
Previously, `end program` would be captured as:

    end_program_statement
      "endprogram"
      "endprogram"

and now it will be captured as:

    end_program_statement
      "end"
      "program"
Previously:

```f90
print*, 'this looks like implicit '&
     'concatenation but isn''t'
print*, "this explicit concatenation "&
     // "is intended"
```

would get parsed as

```
8:2   - 9:33        print_statement
8:2   - 8:7           "print"
8:7   - 8:8           format_identifier
8:7   - 8:8             "*"
8:8   - 8:9           ","
9:7   - 9:33          output_item_list
9:7   - 9:33            string_literal `'concatenation but isn''t'`
10:2  - 11:23       print_statement
10:2  - 10:7          "print"
10:7  - 10:8          format_identifier
10:7  - 10:8            "*"
10:8  - 10:9          ","
11:7  - 11:23         output_item_list
11:7  - 11:23           concatenation_expression
11:7  - 11:7              left: string_literal
11:7  - 11:9              "//"
11:10 - 11:23             right: string_literal `"is intended"`
```

Note first half of literal is missing!

Now gets parsed as:

```
8:2   - 9:33        print_statement
8:2   - 8:7           "print"
8:7   - 8:8           format_identifier
8:7   - 8:8             "*"
8:8   - 8:9           ","
8:10  - 9:33          output_item_list
8:10  - 9:33            string_literal
8:10  - 8:39              `'this looks like implicit '&\n`
9:10  - 9:33              `       'concatenation but isn''t'`
10:2  - 11:23       print_statement
10:2  - 10:7          "print"
10:7  - 10:8          format_identifier
10:7  - 10:8            "*"
10:8  - 10:9          ","
10:10 - 11:23         output_item_list
10:10 - 11:23           concatenation_expression
10:10 - 10:40             left: string_literal `"this explicit concatenation "`
10:40 - 10:41             "&"
11:7  - 11:7              "&"
11:7  - 11:9              "//"
11:10 - 11:23             right: string_literal `"is intended"`
```

Full literal text is now included.

No tests because this is in the CST, and that's not captured in the tests
Previously these were parsed as standalone `call_expression`s, but the
previous change made these ungrammatical.
Previously were just `call_expression`
Also allows parsing `foo()` as a standalone statement, which could be
a compiler extension or preprocessor macro
`mark_end` has to be used with `advance` rather than `skip`, or the
text isn't captured properly in the CST (although the named node may
still exist)

Closes stadelmanma#146
Moving the `_end_of_statement` out of each rule into
`_specification_part` reduces the total number of states and makes it
slightly faster to generate the grammar. Also means that the newline
isn't included in the node itself
…l-continuation

Fix string literals immediately followed by line continuation
…er-keyword-clashes

Fix more keyword/identifier clashes
Allows capturing common block name
@inaki-amatria inaki-amatria requested a review from a team June 23, 2025 11:44
@inaki-amatria inaki-amatria self-assigned this Jun 23, 2025
@inaki-amatria inaki-amatria requested review from daniel-otero and d-alonso and removed request for a team June 23, 2025 11:44
@inaki-amatria
Copy link
Member Author

We decided to squash all commits and merge this change to bypass the current restriction preventing merge commits on the codee branch. Once Dani is back from out of office, we may consider recreating the original commit history.

@inaki-amatria inaki-amatria merged commit 00614f5 into codee Jun 25, 2025
1 check passed
@inaki-amatria inaki-amatria deleted the feature/FinalUpgradeTreeSitterFortranAuto branch June 25, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants